home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 6906 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.5 KB

  1. Path: solon.com!not-for-mail
  2. From: c2a192@ugrad.cs.ubc.ca (Kazimir Kylheku)
  3. Newsgroups: comp.lang.c,comp.lang.c.moderated
  4. Subject: Re: Floating Point arithmetic problem
  5. Date: 16 Feb 1996 00:12:39 -0600
  6. Organization: Computer Science, University of B.C., Vancouver, B.C., Canada
  7. Sender: clc@solutions.solon.com
  8. Approved: clc@solutions.solon.com
  9. Message-ID: <4g178n$mu3@solutions.solon.com>
  10. References: <c968da6jzm.fsf@damayanti.india.ti.com> <4fvi3t$ebe@solutions.solon.com>
  11. NNTP-Posting-Host: solutions.solon.com
  12.  
  13. In article <4fvi3t$ebe@solutions.solon.com>,
  14. Thad Smith <ThadSmith@acm.org> wrote:
  15. >That would, for arbitrary operands, make matters much worse by adding
  16. >additional noise.  Your examples, though, suggest that all your values
  17. >might be multiples of .001 or .0001.  If that is the case, you would
  18. >be much better off scaling your values by a multiplier that results in
  19. >all values being integers, i.e., multiplying by 10000, before summing
  20. >them.  This will reduce the noise produced when adding the numbers,
  21. >probably enough to give you a perfect solution.  Obviously you need to
  22.  
  23. Yes. If there are enough significant bit in the mantissa of whatever
  24. floating-point representation is being used, then all the integers can be
  25. represented. E.g. the double-precision IEEE format has 52 bits, which is plenty
  26. for storing perfect representations of 32-bit integers. The solution I
  27. presented which converts an integer loop variable into floating point may be 
  28. overkill if every integer can be accurately represented.
  29. -- 
  30.